package com.tonglin.springboot.controller;

import com.tonglin.springboot.po.BookOrder;
import com.tonglin.springboot.po.Status01;
import com.tonglin.springboot.service.LoginService;
import com.tonglin.springboot.service.LogonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 *
 *
 * 接受数据
 *
 * 响应页面
 *
 *
 */
@Controller
public class LoginController {

    //接收的用户名
    String name;

    @Autowired
    LoginService loginService;

    @Autowired
    BookController controller;
    @RequestMapping("login")
    public String login(String userName, String passWord,Model model) throws IOException {

        this.name = userName;

        List<String>  list = loginService.orderInfo(userName);

        controller.setUserName(userName);



     if(loginService.login(userName,passWord).isCode()){

        // model.addAttribute("msg",loginService.login(userName,passWord).getMsg());
         model.addAttribute("mm",loginService.login(userName,passWord));
         model.addAttribute("name",userName);
         model.addAttribute("list",list);

         return "msg";

     }else {
         model.addAttribute("msg",loginService.login(userName,passWord).getMsg());

         return "hello";
     }
    }











}
